<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>es6箭头函数</title>
</head>
<body>
    <input type="text" id="mytext">
    <script>
        var test = () => {
            console.log("hello world")
        }
        test()
        
        var test1 = a => a * 10
        console.log(test1(1))

        var test2 = () => ( {
                name: "zhangsan",
                age: 18
            }
        )
        console.log(test2())

        var test3 = function(){
            console.log(arguments, arguments[0], arguments[1], arguments[2])

            console.log(Array.from(arguments)) 
        }
        test3(1, 2, 3, 4, 5)

        var test4 = ()=>{
            console.log(this) 
        }
        test4() 

        //箭头函数的this指向是调用者的父级
        mytext.oninput = function(){
            console.log(this) 
            setTimeout(() => {
                console.log(this.value) 
            }, 1000);
        }

        test5 = (a=1, b=2) => {
            return a + b
        }
        console.log(test5(1))
    </script>
</body>
</html>